navitel: Add support for Navitel binary tracks (.bin).
authoroliskoli <oliskoli>
Wed, 3 Sep 2008 22:10:43 +0000 (22:10 +0000)
committeroliskoli <oliskoli>
Wed, 3 Sep 2008 22:10:43 +0000 (22:10 +0000)
Makefile.in
navitel.c [new file with mode: 0644]
vecs.c

index 816cc598b2eaad719817966f65108c8ae73f12bb..27afa2ef0e5c823ad7a98bd14cf0629f13be49fb 100644 (file)
@@ -59,7 +59,7 @@ ALL_FMTS=$(MINIMAL_FMTS) gtm.o gpsutil.o pcx.o cetus.o copilot.o \
        wbt-200.o stmsdf.o gtrnctr.o dmtlog.o raymarine.o alan.o vitovtt.o \
        ggv_log.o g7towin.o garmin_gpi.o lmx.o random.o xol.o dg-100.o \
        navilink.o mtk_logger.o ik3d.o osm.o destinator.o exif.o vidaone.o \
-       igo8.o gopal.o humminbird.o tr7.o gnav_trl.o
+       igo8.o gopal.o humminbird.o tr7.o gnav_trl.o navitel.o
 
 FMTS=@FMTS@
 
@@ -633,6 +633,8 @@ navilink.o: navilink.c defs.h config.h queue.h gbtypes.h zlib/zlib.h \
   jeeps/gpsapp.h jeeps/gpsprot.h jeeps/gpscom.h jeeps/gpsfmt.h \
   jeeps/gpsmath.h jeeps/gpsmem.h jeeps/gpsrqst.h jeeps/gpsinput.h \
   jeeps/gpsproj.h
+navitel.o: navitel.c defs.h config.h queue.h gbtypes.h \
+  zlib/zlib.h zlib/zconf.h gbfile.h jeeps/gpsmath.h
 netstumbler.o: netstumbler.c defs.h config.h queue.h gbtypes.h \
   zlib/zlib.h zlib/zconf.h gbfile.h cet.h cet_util.h inifile.h csv_util.h
 nmea.o: nmea.c defs.h config.h queue.h gbtypes.h zlib/zlib.h zlib/zconf.h \
diff --git a/navitel.c b/navitel.c
new file mode 100644 (file)
index 0000000..806816c
--- /dev/null
+++ b/navitel.c
@@ -0,0 +1,111 @@
+/*
+
+    Support for Navitel binary tracks (.bin),
+    copyright (C) 2008 Olaf.Klein@gpsbabel.org.
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA
+
+ */
+
+#include <ctype.h>
+#include "defs.h"
+#include "gbfile.h"
+#include "jeeps/gpsmath.h"
+
+#define MYNAME "navitel"
+
+static gbfile *fin, *fout;
+
+/*******************************************************************************
+* %%%        global callbacks called by gpsbabel main process              %%% *
+*******************************************************************************/
+
+static void
+navitel_rd_init(const char *fname)
+{
+       fin = gbfopen(fname, "rb", MYNAME);
+}
+
+static void 
+navitel_rd_deinit(void)
+{
+       gbfclose(fin);
+}
+
+static void
+navitel_read_track(void)
+{
+       int points, i;
+       route_head *trk = NULL;
+       
+       points = gbfgetint32(fin);
+       (void) gbfgetint32(fin); /* unknown */
+       
+       for (i = 0; i < points; i++) {
+               int lat, lon;
+               waypoint *wpt;
+               
+               lon = gbfgetint32(fin);
+               lat = gbfgetint32(fin);
+               
+               wpt = waypt_new();
+               wpt->latitude = GPS_Math_Semi_To_Deg(lat & 0x7FFFFFFF);
+               wpt->longitude = GPS_Math_Semi_To_Deg(lon);
+               
+               if ((lat >> 31) || (trk == NULL)) {
+                       trk = route_head_alloc();
+                       track_add_head(trk);
+               }
+               track_add_wpt(trk, wpt);
+       }
+}
+
+static void
+navitel_wr_init(const char *fname)
+{
+       fout = gbfopen(fname, "wb", MYNAME);
+}
+
+static void
+navitel_wr_deinit(void)
+{
+       gbfclose(fout);
+}
+
+static void
+navitel_write_track(void)
+{
+}
+
+/**************************************************************************/
+
+ff_vecs_t navitel_trk_vecs = {
+       ff_type_file,
+       { 
+               ff_cap_none     /* waypoints */, 
+               ff_cap_read     /* tracks */, 
+               ff_cap_none     /* routes */
+       },
+       navitel_rd_init,        
+       navitel_wr_init,        
+       navitel_rd_deinit,      
+       navitel_wr_deinit,      
+       navitel_read_track,
+       navitel_write_track,
+       NULL,
+       NULL,
+       CET_CHARSET_UTF8, 1                     /* Nothing to convert */
+};
+/**************************************************************************/
diff --git a/vecs.c b/vecs.c
index 0e1ce1d4686fa5f3aa60c9d7e3aa1cf5f13c9e3d..9eb290d0cdbdd87c0622d6815919fdae03dc1ef0 100644 (file)
--- a/vecs.c
+++ b/vecs.c
@@ -145,6 +145,7 @@ extern ff_vecs_t humminbird_vecs;
 extern ff_vecs_t humminbird_ht_vecs;
 extern ff_vecs_t tr7_vecs;
 extern ff_vecs_t gnav_trl_vecs;
+extern ff_vecs_t navitel_trk_vecs;
 
 static
 vecs_t vec_list[] = {
@@ -830,6 +831,13 @@ vecs_t vec_list[] = {
                "Google Navigator Tracklines (.trl)",
                "trl"
        },
+       {
+               &navitel_trk_vecs,
+               "navitel_trk",
+               "Navitel binary tracks (.bin)",
+               "bin"
+       },
+
 #endif // MAXIMAL_ENABLED
        {
                NULL,